package com.yaolong.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yaolong.commons.response.ResponseResult;
import com.yaolong.domain.Camera;
import com.yaolong.service.ICameraService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yaolong.commons.base.BaseController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yaolong
 * @since 2021-04-20
 */
@RestController
@RequestMapping("/camera")
public class CameraController extends BaseController<Camera, ICameraService> {

    private final ICameraService cameraService;

    public CameraController(ICameraService cameraService) {
        this.cameraService = cameraService;
    }


    /**
     * 获取当前地点的摄像头信息列表
     *
     * @param place
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public ResponseResult getCameraList(@RequestParam("place") String place){
        QueryWrapper<Camera> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("place",place);
        List<Camera> cameras = cameraService.getBaseMapper().selectList(queryWrapper);
        return ResponseResult.success(cameras);
    }
}
